window.addEventListener("load", function load(event){  
    window.removeEventListener("load", load, false); //remove listener, no longer needed  
    myExtension.init();    
},false);  
  
var myExtension = {  
  init: function() {  
    var appcontent = document.getElementById("appcontent");   // browser  
    if(appcontent){  
      appcontent.addEventListener("DOMContentLoaded", myExtension.onPageLoad, true);  
    }  
  },  
  
  onPageLoad: function(aEvent) {  
    var doc = aEvent.originalTarget; // doc is document that triggered "onload" event  
    // do something with the loaded page.  
    // doc.location is a Location object (see below for a link).  
    // You can use it to make your code executed on certain pages only.  
    if(doc.location.href.search("http://www.google.com") > -1) {
      doc.location = doc.location.href.replace("http:\/\/","https:\/\/"); 
	  //alert(doc.location.href);
	}
      
    // add event listener for page unload   
    aEvent.originalTarget.defaultView.addEventListener("unload", function(event){ myExtension.onPageUnload(event); }, true);  
  },  
  
  onPageUnload: function(aEvent) {  
    // do something  
  }  
};  